#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    batSet = NULL;

    unitBa[0] = ui->widget;
    unitBa[1] = ui->widget_2;
    unitBa[2] = ui->widget_3;
    unitBa[3] = ui->widget_4;
    unitBa[4] = ui->widget_5;
    unitBa[5] = ui->widget_6;

    for(int i=0; i < 6; i++)
    {
        connect(unitBa[i], &UnitForm::OpenSet, this, &MainWindow::OpenSetForm, Qt::QueuedConnection);
    }

    unitBa[0]->UnitInit(0);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::OpenSetForm(int ID)
{
    if(batSet == NULL)
    {
        batSet = new BatterySet(ID);
        batSet->show();

//        connect(com, &Serial_com::Read_Com, batSet, &BatterySet::com_rec, Qt::QueuedConnection);
//        connect(batSet, &BatterySet::exit_set, this, &MainWindow::close_set, Qt::QueuedConnection);
//        connect(batSet, &BatterySet::SendSet, this, &MainWindow::info_set_send, Qt::QueuedConnection);
    }
}
